import sys, csv
import numpy as np
#import matplotlib.pyplot as plt
src_csv = csv.DictReader(open(sys.argv[1],'rb'))
all_data = {}
for line in src_csv:
	c_year = line['Document'].split("/")[-1].split("_")[1][0:4]
	if c_year not in all_data:
		all_data[c_year]= {}
	for a in line:
		if a == 'Document':
			continue
		if a not in all_data[c_year]:
			all_data[c_year][a]=[]
		all_data[c_year][a].append(float(line[a]))
sorted_docs = sorted([w for w in all_data[c_year].keys() if w!='Document'])
print ",".join(["year"]+sorted_docs)
for year in sorted(all_data.keys(), key=lambda x: int(x)):
	print ",".join([year]+[str(np.mean(all_data[year][a])) for a in sorted_docs])
xs = sorted(all_data.keys(), key=lambda x: int(x))
all_ys = []
'''
for a in sorted_docs:
	all_ys.append([np.mean(all_data[c_year][a]) for c_year in xs])
	plt.plot(xs,all_ys[-1])
plt.show()
'''